package com.fuhao.proxy.dynamicproxy.jdk;

import java.lang.reflect.Proxy;

import com.fuhao.factory.abstractfactory.IUser;

/**
 * jdk动态代理的具体实现类必须要实现接口
 * @author zhang
 *
 */
public class Test {
	public static void main(String[] args) {
		IUserService iService = new UserServiceImpl();
		InvocationHandlerImpl invocationHandlerImpl = new InvocationHandlerImpl(iService);
		ClassLoader loader = iService.getClass().getClassLoader();
		Class<?>[] interfaces = iService.getClass().getInterfaces();
		IUserService newProxyInstance = (IUserService) Proxy.newProxyInstance(loader, interfaces, invocationHandlerImpl);
		newProxyInstance.add();
	}
}
